package com.lungle.warmdiary.app.utils;

import android.os.CountDownTimer;
import android.util.TypedValue;
import android.widget.Button;

/**
 * Created by God
 * on 2016/9/12.
 */
public class CountDownTimerUtil {

    public static CountDownTimer create(final Button button) {

        return new CountDownTimer(60000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
                button.setText(millisUntilFinished / 1000 + "秒后\n重新获取");
                button.setClickable(true);
                button.setEnabled(false);
            }

            @Override
            public void onFinish() {
                button.setClickable(true);
                button.setEnabled(true);
                button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
                button.setText("获取验证码");
            }
        };
    }


}
